Hi,
Stream outputFile = write "PerformanceIndicators.txt"
// declare filter
Filter fCategoryRequirements = (attribute "Category" != "Comment") && (attribute "Category" != "Heading")
Filter fStateReleased = (attribute "State" == "Released")
// set filter and return number of accepted objects
void getFilterResults(Module m, Filter f){
int iAccepted = 0
int iRejected = 0
set(m, f, iAccepted, iRejected) //<-- *** HERE IS THE PROBLEM ***
outputFile << "|" iAccepted "" //"" converts "int" to "string"
}
//Module1
Module m1 = read(fullName itemFromID("00000610"), false) //open module to read
outputFile << name(m1) " (" uniqueID(m1) ")" //write modulename + ID
outputFile << stringOf(m1, fCategoryRequirements) //output filter
getFilterResults(m1, fCategoryRequirements)
close(m1)
//Module2
Module m2 = read(fullName itemFromID("0000074c"), false) //open module to read
outputFile << "\n" name(m2) " (" uniqueID(m2) ")" //write modulename + ID
outputFile << "\n" stringOf(m2, fStateReleased) //output filter
getFilterResults(m2, fCategoryRequirements)
close(m2)
-R-E- DXL: <Line:12> An unexpected error has occurred: doors.exe caused an EXCEPTION_ACCESS_VIOLATION in module doors.exe at 001B:004B31D6
Johnny_P - Mon Feb 20 10:54:12 EST 2012 |
Re: Filtering in various Modules You need to take care, when declaring the filter. The filters are declared in the scope of a module, however you declare the filters at the start of your script. Make sure you set a current module, then declare the filter. This should resolve the crash problems:
Stream outputFile = write "PerformanceIndicators.txt"
// declare filter
// set filter and return number of accepted objects
void getFilterResults(Module m, Filter f){
int iAccepted = 0
int iRejected = 0
set(m, f, iAccepted, iRejected) //<-- *** HERE IS THE PROBLEM ***
outputFile << "|" iAccepted "" //"" converts "int" to "string"
}
//Module1
Module m1 = read(fullName itemFromID("00000610"), false) //open module to read
current = m1; Filter fCategoryRequirements = (attribute "Category" != "Comment") && (attribute "Category" != "Heading")
outputFile << name(m1) " (" uniqueID(m1) ")" //write modulename + ID
outputFile << stringOf(m1, fCategoryRequirements) //output filter
getFilterResults(m1, fCategoryRequirements)
close(m1)
//Module2
Module m2 = read(fullName itemFromID("0000074c"), false) //open module to read
current = m2; Filter fStateReleased = (attribute "State" == "Released")
outputFile << "\n" name(m2) " (" uniqueID(m2) ")" //write modulename + ID
outputFile << "\n" stringOf(m2, fStateReleased) //output filter
getFilterResults(m2, fCategoryRequirements)
close(m2)
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Filtering in various Modules Stream outputFile = write "PerformanceIndicators.txt"
Filter fCategoryRequirements = (attribute "Category" != "Comment") && (attribute "Category" != "Heading")
After you open a module you should set it current if you use implied "current Module" stuff like Filters as suggested by Mathias:
Seems to me you are more likely to know the full name of your desired modules than you are their unique IDs.
Seems to me that your script is at the mercy of the default view, such as if it excludes levels or does show deleted objects. To resolve this (and to avoid nasty Layouts and to open faster) use the 3rd parameter to "read", open the Standard view so you know the state of the module before you start filtering.
Your Filter isn't going to work when you open the module invisibly "false". Hate it when that happens and you are counting 100 modules; it takes up your monitor and runs drastically slower.
I'm not sure I've ever actually deployed a DXL using a "Filter" and certainly never as a mechanism for counting objects. Perhaps do something like this:
int CountQualifyingObjects(Module mod)
{ Object obj
int Count = 0
string AttrVal
for obj in entire mod do
{ if (isDeleted(obj)) continue
AttrVal = obj."Category"
if (AttrVal != "Comment" and AttrVal != "Heading") Count++
}
return(Count)
}
|
Re: Filtering in various Modules @Matthias Declaring the filters after the module (like in your example) does not work for me. I get the same error. Thank you for the linked thread! This looks interresting and maybe I can use some parts of this idea! @Louie
Thanks, I changed that.
There are no Objects with no category in our modules.
Category is a single choise attribute.
We have different kinds of requirements in our modules and I wanted to use the filter for all Modules. So I thougt I exclude all non requirement objects.
Thanks, I added this.
Yeah, I had it like this the first time, but recently we changed a lot of modulenames, so I thougt using the ID saves me labour in the future.
I changed these two advices too. And thank you for your example code. Actually I'm using a mix of my old code and yours now. Due to heavy time pressure the code is a little mixup and not so clean at the moment. When there is the opportunity I'm going to clean it up and then I think I can post it here ;) BR, Johnny |